/*
 * @Author: Lin Hongwei
 * @Date: 2021-12-06 15:12:12
 * @LastEditTime: 2021-12-06 16:00:11
 * @LastEditors: Lin Hongwei
 * @email: 1365755396@qq.com
 * @CSDN: https://blog.csdn.net/weixin_45429409
 * @Description: 生产环境配置文件
 */
const BaseConfig = require("./webpack.config");
const {merge:WebpackMerge,mergeWithCustomize, unique} = require("webpack-merge");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");//打包html
const OptimizeCssAssetsWebpackPlugin = require("optimize-css-assets-webpack-plugin");
const ProdConfig = {
    mode:"development",
    plugins:[
        new OptimizeCssAssetsWebpackPlugin(),
        new HtmlWebpackPlugin({
            title:"epub电子书阅读器",
            template:path.resolve(__dirname,"public/index.html"),
            minify:{
                collapseWhitespace:true,
                removeComments:true,
                removeAttributeQuotes:true
            },
            hash:true
        })
    ]
    
}

const WebpackConfig = mergeWithCustomize({
    customizeArray:unique(
        "plugins",
        ["HtmlWebpackPlugin"],
        (plugin)=>plugin.constructor&&plugin.constructor.name
    )
})(BaseConfig,ProdConfig)

module.exports = WebpackConfig
